<!DOCTYPE html>
<html lang="zh">
    <head>
    <!--
        © Material Theme
        https://github.com/viosey/hexo-theme-material
        Version: 1.3.4 -->

    <!-- Title -->
    
    <title>
        
            JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取) | 
        
        Twilight&#39;s Blog
    </title>

    <!-- Meta & Info -->
    <meta charset="utf-8">

    <!-- dns prefetch -->
    <meta http-equiv="x-dns-prefetch-control" content="on">
    
    
        <link rel="dns-prefetch" href="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"/>
    
    
        <link rel="dns-prefetch" href="https://changyan.sohu.com"/>
    
    
    
    

    <meta http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="theme-color" content="#0097A7">
    <meta name="author" content="wangchao">
    <meta name="description" content="null">
    <meta name="keywords" content="null,JSP">

    <!-- Favicons -->
    <link rel="icon shortcut" type="image/ico" href="/img/favicon.png">
    <link rel="icon" sizes="192x192" href="/img/favicon.png">
    <link rel="apple-touch-icon" href="/img/favicon.png">

    <!--iOS -->
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-title" content="Title">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="480">

    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">

    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Twilight&#39;s Blog">

    <!-- The Open Graph protocol -->
    <meta property="og:url" content="http://yoursite.com">
    <meta property="og:type" content="blog">
    <meta property="og:title" content="JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取) | Twilight&#39;s Blog">
    <meta property="og:description" content="null">
    <meta property="og:article:tag" content="JSP"> 

    <!--[if lte IE 9]>
        <link rel="stylesheet" href="/css/ie-blocker.css">

        
            <script src="/js/ie-blocker.zhCN.js"></script>
        
    <![endif]-->

    <!-- Import CSS & jQuery -->
    
        <link rel="stylesheet" href="/css/material.min.css">
        <link rel="stylesheet" href="/css/style.min.css">
        <!-- Config CSS -->


<!-- Other Styles -->
<style>
  body, html {
    font-family: Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  }

  a {
    color: #00838F;
  }

  .mdl-card__media,
  #search-label,
  #search-form-label:after,
  #scheme-Paradox .hot_tags-count,
  #scheme-Paradox .sidebar_archives-count,
  #scheme-Paradox .sidebar-colored .sidebar-header,
  #scheme-Paradox .sidebar-colored .sidebar-badge{
    background-color: #0097A7 !important;
  }

  /* Sidebar User Drop Down Menu Text Color */
  #scheme-Paradox .sidebar-colored .sidebar-nav>.dropdown>.dropdown-menu>li>a:hover,
  #scheme-Paradox .sidebar-colored .sidebar-nav>.dropdown>.dropdown-menu>li>a:focus {
    color: #0097A7 !important;
  }

  #post_entry-right-info,
  .sidebar-colored .sidebar-nav li:hover > a,
  .sidebar-colored .sidebar-nav li:hover > a i,
  .sidebar-colored .sidebar-nav li > a:hover,
  .sidebar-colored .sidebar-nav li > a:hover i,
  .sidebar-colored .sidebar-nav li > a:focus i,
  .sidebar-colored .sidebar-nav > .open > a,
  .sidebar-colored .sidebar-nav > .open > a:hover,
  .sidebar-colored .sidebar-nav > .open > a:focus,
  #ds-reset #ds-ctx .ds-ctx-entry .ds-ctx-head a {
    color: #0097A7 !important;
  }

  .toTop {
    background: #757575 !important;
  }

  .material-layout .material-post>.material-nav,
  .material-layout .material-index>.material-nav,
  .material-nav a {
    color: #757575;
  }

  #scheme-Paradox .MD-burger-layer {
    background-color: #757575;
  }

  #scheme-Paradox #post-toc-trigger-btn {
    color: #757575;
  }

  .post-toc a:hover {
    color: #00838F;
    text-decoration: underline;
  }

</style>


<!-- Theme Background Related-->

    <style>
      body{
        background-image: url(/img/bg.jpg);
      }
    </style>




<!-- Fade Effect -->

    <style>
      .fade {
        transition: all 800ms linear;
        -webkit-transform: translate3d(0,0,0);
        -moz-transform: translate3d(0,0,0);
        -ms-transform: translate3d(0,0,0);
        -o-transform: translate3d(0,0,0);
        transform: translate3d(0,0,0);
        opacity: 1;
      }

      .fade.out{
        opacity: 0;
      }
    </style>


        <script src="/js/jquery.min.js"></script>
        <script src="/js/queue.js"></script>
    

    <!-- UC Browser Compatible -->
    <script>
        var agent = navigator.userAgent.toLowerCase();
        if(agent.indexOf('ucbrowser')>0) {
            document.write("<link rel=\"stylesheet\" href=\"/css/uc.css\">");
            alert('由于 UC 浏览器使用极旧的内核，而本网站使用了一些新的特性。\n为了您能更好的浏览，推荐使用 Chrome 或 Firefox 浏览器。');
        }
    </script>

    

    


    <!-- Bing Background -->
    

    <!-- Custom Head -->
    
</head>


    
        <body id="scheme-Paradox" class="lazy">
            <div class="material-layout  mdl-js-layout has-drawer is-upgraded">
                

                <!-- Main Container -->
                <main class="material-layout__content" id="main">

                    <!-- Top Anchor -->
                    <div id="top"></div>

                    
                        <!-- Hamburger Button -->
                        <button class="MD-burger-icon sidebar-toggle">
                            <span class="MD-burger-layer"></span>
                        </button>
                    

                    <!-- Post TOC -->

    
    <!-- Back Button -->
    <!--
    <div class="material-back" id="backhome-div" tabindex="0">
        <a class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon"
           href="#" onclick="window.history.back();return false;"
           target="_self"
           role="button"
           data-upgraded=",MaterialButton,MaterialRipple">
            <i class="material-icons" role="presentation">arrow_back</i>
            <span class="mdl-button__ripple-container">
                <span class="mdl-ripple"></span>
            </span>
        </a>
    </div>
    -->

    <!-- Left aligned menu below button -->
    <button id="post-toc-trigger-btn"
        class="mdl-button mdl-js-button mdl-button--icon">
        <i class="material-icons">format_list_numbered</i>
    </button>

    <ul class="post-toc-wrap mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect" for="post-toc-trigger-btn" style="max-height:80vh; overflow-y:scroll;">
        <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#使用JSTL"><span class="post-toc-number">1.</span> <span class="post-toc-text">使用JSTL</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#输出语句out"><span class="post-toc-number">2.</span> <span class="post-toc-text">输出语句out</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#赋值语句set"><span class="post-toc-number">3.</span> <span class="post-toc-text">赋值语句set</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#捕获异常语句catch"><span class="post-toc-number">4.</span> <span class="post-toc-text">捕获异常语句catch</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#移除属性remove"><span class="post-toc-number">5.</span> <span class="post-toc-text">移除属性remove</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#简单判断语句if"><span class="post-toc-number">6.</span> <span class="post-toc-text">简单判断语句if</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#复杂判断语句-choose、when、otherwise-实现条件判断"><span class="post-toc-number">7.</span> <span class="post-toc-text">复杂判断语句 choose、when、otherwise 实现条件判断</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#循环语句-forEach"><span class="post-toc-number">8.</span> <span class="post-toc-text">循环语句 forEach</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#字符串截取-fortakens"><span class="post-toc-number">9.</span> <span class="post-toc-text">字符串截取 fortakens</span></a></li></ol>

        <!--
        <li class="mdl-menu__item">
            Some Action
        </li>
        -->
    </ul>




<!-- Layouts -->

    <!-- Post Module -->
    <div class="material-post_container">

        <div class="material-post mdl-grid">
            <div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">

                <!-- Post Header(Thumbnail & Title) -->
                
    <!-- Paradox Post Header -->
    
        <!-- Custom Thumbnail -->
        <div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(http://otbrtx8bw.bkt.clouddn.com/hexo_title53.jpg)">
    
            <p class="article-headline-p">
                JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取)
            </p>
        </div>





                
                    <!-- Paradox Post Info -->
                    <div class="mdl-color-text--grey-700 mdl-card__supporting-text meta">

    <!-- Author Avatar -->
    <div id="author-avatar">
        <img src="/img/avatar.png" width="44px" height="44px" alt="Author Avatar"/>
    </div>
    <!-- Author Name & Date -->
    <div>
        <strong>wangchao</strong>
        <span>7月 22, 2017</span>
    </div>

    <div class="section-spacer"></div>

    <!-- Favorite -->
    <!--
        <button id="article-functions-like-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon btn-like">
            <i class="material-icons" role="presentation">favorite</i>
            <span class="visuallyhidden">favorites</span>
        </button>
    -->

    <!-- Qrcode -->
    

    <!-- Tags (bookmark) -->
    
    <button id="article-functions-viewtags-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
        <i class="material-icons" role="presentation">bookmark</i>
        <span class="visuallyhidden">bookmark</span>
    </button>
    <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-functions-viewtags-button">
        <li class="mdl-menu__item">
        <a class="post_tag-link" href="/tags/JSP/">JSP</a>
    </ul>
    

    <!-- Share -->
    <button id="article-fuctions-share-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
    <i class="material-icons" role="presentation">share</i>
    <span class="visuallyhidden">share</span>
</button>
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-fuctions-share-button">
    
    <!-- Leancloud Views -->
        <a class="post_share-link" href="#">
            <li class="mdl-menu__item">
                <span id="/2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/" class="leancloud-views_num" data-flag-title="JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取)">
     &nbsp;浏览量
</span>

            </li>
        </a>
    

    

    <!-- Share Weibo -->
    
        <a class="post_share-link" href="http://service.weibo.com/share/share.php?appkey=&title=JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取)&url=http://yoursite.com//2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/index.html&pic=&searchPic=false&style=simple" target="_blank">
            <li class="mdl-menu__item">
                分享到微博
            </li>
        </a>
    

    <!-- Share Twitter -->
    
        <a class="post_share-link" href="https://twitter.com/intent/tweet?text=JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取)&url=http://yoursite.com//2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/index.html&via=wangchao" target="_blank">
            <li class="mdl-menu__item">
                分享到 Twitter
            </li>
        </a>
    

    <!-- Share Facebook -->
    
        <a class="post_share-link" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com//2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/index.html" target="_blank">
            <li class="mdl-menu__item">
                分享到 Facebook
            </li>
        </a>
    

    <!-- Share Google+ -->
    
        <a class="post_share-link" href="https://plus.google.com/share?url=http://yoursite.com//2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/index.html" target="_blank">
            <li class="mdl-menu__item">
                分享到 Google+
            </li>
        </a>
    

    <!-- Share LinkedIn -->
    

    <!-- Share QQ -->
    
        <a class="post_share-link" href="http://connect.qq.com/widget/shareqq/index.html?site=Twilight&#39;s Blog&title=JSP---使用JSTL(out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取)&summary=null&pics=http://yoursite.com/img/favicon.png&url=http://yoursite.com/2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/index.html" target="_blank">
            <li class="mdl-menu__item">
                分享到 QQ
            </li>
        </a>
    

    <!-- Share Telegram -->
    
</ul>

</div>

                

                <!-- Post Content -->
                <div id="post-content" class="mdl-color-text--grey-700 mdl-card__supporting-text fade out">
    
        <h1 id="使用JSTL"><a href="#使用JSTL" class="headerlink" title="使用JSTL"></a>使用JSTL</h1><p>在MyEclipse2014中，使用JSTL只要在文件开始加上一句<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jsp/jstl/core&quot; %&gt;</div></pre></td></tr></table></figure></p>
<p>prefix表示前缀，用于区分其他标签，可以自定义前缀。<br>使用JSTL可以进一步减少Scriptlet的使用。使前端页面更加简洁</p>
<h1 id="输出语句out"><a href="#输出语句out" class="headerlink" title="输出语句out"></a>输出语句out</h1><p><strong>&lt;c:out value=”value” default=”default” escapeXml=”true/false” &gt;&lt;/c:out&gt;</strong></p>
<ul>
<li>输出常量：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;c:out value=&quot;test&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<ul>
<li>输出变量</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">&lt;% String username = &quot;tom&quot;;session.setAttribute(&quot;username&quot;, username); %&gt;</div><div class="line">&lt;c:out value=&quot;username: $&#123;username&#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<ul>
<li>当没有获取到值时，采用默认值</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;c:out value=&quot;$&#123;username2&#125;&quot; default=&quot;default&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<ul>
<li>当出现特殊字符时，是否保留(false-不保留|true-保留)</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">&lt;c:out value=&quot;&amp;lt;out&amp;gt;&quot; escapeXml=&quot;false&quot;&gt;&lt;/c:out&gt;	// &lt;out&gt;</div><div class="line">&lt;c:out value=&quot;&amp;ltout&amp;gt&quot; escapeXml=&quot;false&quot;&gt;&lt;/c:out&gt;		// &lt;out&gt;</div></pre></td></tr></table></figure>
<h1 id="赋值语句set"><a href="#赋值语句set" class="headerlink" title="赋值语句set"></a>赋值语句set</h1><p><strong>&lt;c:set value=”value” var=”var”  scope=”session”  [target=”” property=””]&gt;&lt;/c:set&gt;</strong><br>表示把值value储存到var变量中，变量储存的范围是scope指定的范围。如果不指定scope，则scope取默认值page</p>
<ul>
<li>为变量赋值：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">// 将username变量赋值为zhangsan，并保存到sessionScope中</div><div class="line">    &lt;c:set value=&quot;zhangsan&quot; var=&quot;username&quot;  scope=&quot;session&quot;&gt;&lt;/c:set&gt;</div><div class="line">    &lt;c:out value=&quot;$&#123;sessionScope.username &#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<ul>
<li>赋值时value可以不写，将value的内容写在标签之中也可：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">// 将变量address赋值为‘合肥市’</div><div class="line">    &lt;c:set var=&quot;address&quot; scope=&quot;page&quot;&gt;合肥市&lt;/c:set&gt;</div><div class="line">    &lt;c:out value=&quot;$&#123;pageScope.address &#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<ul>
<li>向JavaBean中赋值：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">// 声名JavaBean</div><div class="line">&lt;jsp:useBean id=&quot;user&quot; class=&quot;Bean.JavaBean&quot;&gt;&lt;/jsp:useBean&gt;</div><div class="line"></div><div class="line">// 将id为user的JavaBean中name属性赋值为‘zhangsan’</div><div class="line">   &lt;c:set target=&quot;$&#123;user&#125;&quot; property=&quot;name&quot; value=&quot;zhangsan&quot;&gt;&lt;/c:set&gt;</div><div class="line">   &lt;c:out value=&quot;$&#123;pageScope.user.name &#125;&quot;&gt;&lt;/c:out&gt;</div><div class="line">   &lt;c:out value=&quot;$&#123;user.name &#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<ul>
<li>和之前一样，value可以包围在标签中</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">&lt;c:set target=&quot;$&#123;user &#125;&quot; property=&quot;password&quot; &gt;123&lt;/c:set&gt;</div><div class="line">&lt;c:out value=&quot;$&#123;user.password &#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<p><strong>PS：以上的例子中，直接使用了<code>${user,name}</code>,是因为，JavaBean在翻译时被自动保存到pageScope中，因此使用JavaBean时可以直接用EL获得JavaBean，而不需要调用setAttribute()方法传递参数：</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">Bean.JavaBean user = null;</div><div class="line">user = (Bean.JavaBean) _jspx_page_context.getAttribute(&quot;user&quot;, javax.servlet.jsp.PageContext.PAGE_SCOPE);</div><div class="line">if (user == null)&#123;</div><div class="line">  user = new Bean.JavaBean();</div><div class="line">  _jspx_page_context.setAttribute(&quot;user&quot;, user, javax.servlet.jsp.PageContext.PAGE_SCOPE);</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h1 id="捕获异常语句catch"><a href="#捕获异常语句catch" class="headerlink" title="捕获异常语句catch"></a>捕获异常语句catch</h1><p>catch包围的语句出现错误时，会将异常保存在var中，可以使用EL表达式获得err的值<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">&lt;c:catch var=&quot;error&quot;&gt;</div><div class="line">	&lt;c:set target=&quot;sss&quot; property=&quot;sss&quot; value=&quot;123&quot;&gt;&lt;/c:set&gt;</div><div class="line">&lt;/c:catch&gt;</div><div class="line">&lt;c:out value=&quot;$&#123;error &#125;&quot; &gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure></p>
<p>结果：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">javax.servlet.jsp.JspTagException: Invalid property in &amp;lt;set&amp;gt;: &quot;sss&quot;</div></pre></td></tr></table></figure></p>
<h1 id="移除属性remove"><a href="#移除属性remove" class="headerlink" title="移除属性remove"></a>移除属性remove</h1><p><strong>&lt;c:remove var=”username” scope=”scope”&gt;&lt;/c:remove&gt;</strong><br>从scope范围中移除var变量。其中var时必须的，scope是可选的</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">&lt;c:set var=&quot;username&quot; value=&quot;tim&quot; scope=&quot;application&quot;&gt;&lt;/c:set&gt;</div><div class="line">&lt;c:out value=&quot;$&#123;username &#125;&quot; &gt;&lt;/c:out&gt;</div><div class="line"></div><div class="line">&lt;!-- var属性必选，scope可选 --&gt;</div><div class="line">&lt;c:remove var=&quot;username&quot; &gt;&lt;/c:remove&gt;</div><div class="line">&lt;c:out value=&quot;$&#123;username &#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<h1 id="简单判断语句if"><a href="#简单判断语句if" class="headerlink" title="简单判断语句if"></a>简单判断语句if</h1><p><strong>&lt;c:if test=”${param.score&gt;=90 }” var=”result” scope=”application”&gt;</strong><br>test表示判断的条件，var表示判断的结果，scope表示保存判断结果的范围。与Java中的if语句不同该语句没有else，如果要实现if else-if 则需要用choose语句。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">&lt;c:if test=&quot;$&#123;param.score&gt;=90 &#125;&quot; var=&quot;result&quot; scope=&quot;application&quot;&gt;</div><div class="line">		&lt;c:out value=&quot;优秀&quot; &gt;&lt;/c:out&gt;</div><div class="line">&lt;/c:if&gt;</div><div class="line"></div><div class="line">&lt;c:out value=&quot;sss $&#123;applicationScope.result &#125;&quot;&gt;&lt;/c:out&gt;</div></pre></td></tr></table></figure>
<h1 id="复杂判断语句-choose、when、otherwise-实现条件判断"><a href="#复杂判断语句-choose、when、otherwise-实现条件判断" class="headerlink" title="复杂判断语句 choose、when、otherwise 实现条件判断"></a>复杂判断语句 choose、when、otherwise 实现条件判断</h1><p>choose、when、otherwise嵌套使用可以实现if else-if else 条件判断。otherwise类似于Java中的else，可以省略不写。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;c:choose&gt;</div><div class="line">	&lt;c:when test=&quot;$&#123;param.score&gt;=90 &amp;&amp; param.score&lt;=100 &#125;&quot;&gt;</div><div class="line">		&lt;c:out value=&quot;优秀&quot;&gt;&lt;/c:out&gt;</div><div class="line">	&lt;/c:when&gt;</div><div class="line">	&lt;c:when test=&quot;$&#123;param.score&gt;=60 &amp;&amp; param.score&lt;90 &#125;&quot;&gt;</div><div class="line">		&lt;c:out value=&quot;良好&quot;&gt;&lt;/c:out&gt;</div><div class="line">	&lt;/c:when&gt;</div><div class="line">	&lt;c:otherwise&gt;</div><div class="line">		&lt;c:out value=&quot;输入有误&quot;&gt;&lt;/c:out&gt;</div><div class="line">	&lt;/c:otherwise&gt;</div><div class="line">&lt;/c:choose&gt;</div></pre></td></tr></table></figure>
<h1 id="循环语句-forEach"><a href="#循环语句-forEach" class="headerlink" title="循环语句 forEach"></a>循环语句 forEach</h1><p><strong>&lt;c:forEach var=”fruit” items=”${fruits }” begin=”0” end=”4” step=”1” varStatus=”fru”&gt;&lt;/c:forEach&gt;</strong><br>属性：</p>
<ul>
<li>items ： 表示变量的集合</li>
<li>var ： 表示每次从集合中取出的值</li>
<li>begin ： 如果指定了items，那么迭代就从items[begin]开始进行迭代；如果没有指定items，那么就从begin开始迭代。它的类型为整数</li>
<li>end ： 如果指定了items，那么就在items[end]结束迭代；如果没有指定items，那么就在end结束迭代。它的类型也为整数</li>
<li>step ： 步长</li>
<li>varStatus ： 通过index、count、first、last 4个状态值，描述begin和end子集中元素的状态</li>
</ul>
<p>varStaus的4个取值：</p>
<ul>
<li>index ： 当前元素在集合中的下标，起始位0</li>
<li>count ： 当前元素在begin、end子集中的序号，起始位为1</li>
<li>first ： 判断当前元素是不是当前子集的首元素，true/false</li>
<li>last  ： 判断当前元素是不是当卡子集的末尾元素，true/false </li>
</ul>
<p><strong>PS：</strong></p>
<ul>
<li><strong>遍历Map时，var中的对象会是entry，需要手动调用getKey() 和 getValue()方法</strong></li>
<li><strong>切割字符串，默认字符串之间用逗号隔开，forEach会以逗号为分隔符，将字符转拆分开，如果需要自定义分隔符，则需要使用forTakens</strong></li>
</ul>
<p>有以下集合：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">&lt;%</div><div class="line">  	List&lt;String&gt; fruits = new  ArrayList&lt;String&gt;();</div><div class="line">  	fruits.add(&quot;apple&quot;);</div><div class="line">  	fruits.add(&quot;pear&quot;);</div><div class="line">  	fruits.add(&quot;watermelon&quot;);</div><div class="line">  	fruits.add(&quot;orange&quot;);</div><div class="line">  	</div><div class="line">  	request.setAttribute(&quot;fruits&quot;, fruits);</div><div class="line">%&gt;</div></pre></td></tr></table></figure></p>
<ul>
<li>全部遍历</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">&lt;c:forEach var=&quot;fruit&quot; items=&quot;$&#123;fruits &#125;&quot;&gt;</div><div class="line">	&lt;c:out value=&quot;$&#123;fruit &#125;&quot;&gt;&lt;/c:out&gt;</div><div class="line">	&lt;br /&gt;</div><div class="line">&lt;/c:forEach&gt;</div><div class="line"></div><div class="line">// 结果</div><div class="line">		apple </div><div class="line">		pear </div><div class="line">		watermelon </div><div class="line">		orange</div></pre></td></tr></table></figure>
<ul>
<li>部分遍历,闭合区间[begin,end]</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">&lt;c:forEach var=&quot;fruit&quot; items=&quot;$&#123;fruits &#125;&quot; begin=&quot;1&quot; end=&quot;3&quot;&gt;</div><div class="line">	&lt;c:out value=&quot;$&#123;fruit &#125;&quot;&gt;&lt;/c:out&gt;</div><div class="line">	&lt;br /&gt;</div><div class="line">&lt;/c:forEach&gt;</div><div class="line">结果：</div><div class="line">		pear </div><div class="line">		watermelon </div><div class="line">		orange</div></pre></td></tr></table></figure>
<ul>
<li>部分遍历，指定步长</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">&lt;c:forEach var=&quot;fruit&quot; items=&quot;$&#123;fruits &#125;&quot; begin=&quot;0&quot; end=&quot;4&quot; step=&quot;2&quot;&gt;</div><div class="line">	&lt;c:out value=&quot;$&#123;fruit &#125;&quot;&gt;&lt;/c:out&gt;</div><div class="line">	&lt;br /&gt;</div><div class="line">&lt;/c:forEach&gt;</div><div class="line">结果：</div><div class="line">		apple </div><div class="line">		watermelon</div></pre></td></tr></table></figure>
<ul>
<li>使用varStatus获得当前元素状态</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div></pre></td><td class="code"><pre><div class="line">&lt;c:forEach var=&quot;fruit&quot; items=&quot;$&#123;fruits &#125;&quot; begin=&quot;1&quot; end=&quot;3&quot; step=&quot;1&quot; varStatus=&quot;fru&quot;&gt;</div><div class="line">	&lt;c:out value=&quot;$&#123;fruit &#125;&quot;&gt;&lt;/c:out&gt;&lt;br /&gt;</div><div class="line">	&lt;c:out value=&quot;count:$&#123;fru.count &#125;&quot;&gt;&lt;/c:out&gt;&lt;br /&gt;</div><div class="line">	&lt;c:out value=&quot;index: $&#123;fru.index &#125;&quot;&gt;&lt;/c:out&gt;&lt;br /&gt;</div><div class="line">	&lt;c:out value=&quot;first:$&#123;fru.first &#125;&quot;&gt;&lt;/c:out&gt;&lt;br /&gt;</div><div class="line">	&lt;c:out value=&quot;last:$&#123;fru.last &#125;&quot;&gt;&lt;/c:out&gt;&lt;br /&gt;</div><div class="line">	&lt;c:out value=&quot;-----------&quot;&gt;&lt;/c:out&gt;&lt;br /&gt;</div><div class="line">	&lt;br /&gt;</div><div class="line">&lt;/c:forEach&gt;</div><div class="line"></div><div class="line">结果：</div><div class="line">	pear</div><div class="line">	count:1</div><div class="line">	index: 1</div><div class="line">	first:true</div><div class="line">	last:false</div><div class="line">	-----------</div><div class="line">	</div><div class="line">	watermelon</div><div class="line">	count:2</div><div class="line">	index: 2</div><div class="line">	first:false</div><div class="line">	last:false</div><div class="line">	-----------</div><div class="line">	</div><div class="line">	orange</div><div class="line">	count:3</div><div class="line">	index: 3</div><div class="line">	first:false</div><div class="line">	last:true</div><div class="line">	-----------</div></pre></td></tr></table></figure>
<ul>
<li>切割字符串，默认以逗号为分隔符：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&lt;c:forEach var=&quot;word&quot; items=&quot;abc,edf,g&quot;&gt;</div><div class="line">	 	&lt;c:out value=&quot;$&#123;word &#125;&quot;&gt;&lt;/c:out&gt;</div><div class="line">&lt;/c:forEach&gt;</div></pre></td></tr></table></figure>
<ul>
<li>遍历Map，var中是entry对象：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"> &lt;%</div><div class="line"> 	Map&lt;String,String&gt; map = new HashMap&lt;String, String&gt;();</div><div class="line"> 	map.put(&quot;name&quot;, &quot;tom&quot;);</div><div class="line"> 	map.put(&quot;password&quot;,&quot;123&quot;);</div><div class="line"> 	pageContext.setAttribute(&quot;map&quot;, map);</div><div class="line"> %&gt;</div><div class="line">&lt;c:forEach var=&quot;entry&quot; items=&quot;$&#123;map &#125;&quot;&gt;</div><div class="line">	&lt;c:out value=&quot;$&#123;entry.key &#125;:$&#123;entry.value &#125;&quot;&gt;&lt;/c:out&gt;&lt;br/&gt;</div><div class="line">&lt;/c:forEach&gt;</div></pre></td></tr></table></figure>
<h1 id="字符串截取-fortakens"><a href="#字符串截取-fortakens" class="headerlink" title="字符串截取 fortakens"></a>字符串截取 fortakens</h1><p><strong>&lt;c:forTokens var=”str” items=”abc-def-ghi-jkl-mn-opq”  delims=”-“ begin=”0” end=”4” step=”1” varStatus=”strstate”&gt;&lt;/c:forTokens&gt;</strong><br>与ForEach功能不同，但是用法类似。items表示要操作的字符串，delims（delimiter）表示分隔符，var代表每次取值的变量，begin、end表示开始结束位置，varStatus表示状态，这几个属性用法与ForEach一样。</p>
<p>截取前5的单词：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">&lt;c:forTokens items=&quot;abc-def-ghi-jkl-mn-opq&quot; delims=&quot;-&quot; var=&quot;str&quot; begin=&quot;0&quot; end=&quot;4&quot;&gt;</div><div class="line">	&lt;c:out value=&quot;$&#123;str &#125;&quot;&gt;&lt;/c:out&gt;&lt;br/&gt;</div><div class="line">&lt;/c:forTokens&gt;</div><div class="line"></div><div class="line">结果：</div><div class="line">	abc</div><div class="line">	def</div><div class="line">	ghi</div><div class="line">	jkl</div><div class="line">	mn</div></pre></td></tr></table></figure></p>

    

    
</div>


                

                <!-- Post Comments -->
                
                    


    <!-- 使用 changyan -->
    <div id="changyan-comment">
        <!--PC和WAP自适应版-->
<div id="SOHUCS" sid="2017/07/22/JSP-使用JSTL-out、set、remove、catch捕捉异常、条件判断、流程控制、字符截取/"  ></div>
<script type="text/javascript">
(function(){
var appid = 'cysVH2p6S';
var conf = '7d191ef850d424bb873df33179309db5';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>

    </div>
    <style>
        #changyan-comment{
            background-color: #eee;
            padding: 2pc;
        }
    </style>






                
            </div>

            <!-- Post Prev & Next Nav -->
            <nav class="material-nav mdl-color-text--grey-50 mdl-cell mdl-cell--12-col">
    <!-- Prev Nav -->
    
        <a href="/2017/07/22/JSP-JSTL-import、redirect、url处理、常用函数/" id="post_nav-newer" class="prev-content">
            <button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
                <i class="material-icons">arrow_back</i>
            </button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            新篇
        </a>
    

    <!-- Section Spacer -->
    <div class="section-spacer"></div>

    <!-- Next Nav -->
    
        <a href="/2017/07/20/JSP-EL表达式/" id="post_nav-older" class="next-content">
            旧篇
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
                <i class="material-icons">arrow_forward</i>
            </button>
        </a>
    
</nav>

        </div>
    </div>



                    
                        <!-- Overlay For Active Sidebar -->
<div class="sidebar-overlay"></div>

<!-- Material sidebar -->
<aside id="sidebar" class="sidebar sidebar-colored sidebar-fixed-left" role="navigation">
    <div id="sidebar-main">
        <!-- Sidebar Header -->
        <div class="sidebar-header header-cover" style="background-image: url(/img/sidebar_header.jpg);">
    <!-- Top bar -->
    <div class="top-bar"></div>

    <!-- Sidebar toggle button -->
    <button type="button" class="sidebar-toggle mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon" style="display: initial;" data-upgraded=",MaterialButton,MaterialRipple">
        <i class="material-icons">clear_all</i>
        <span class="mdl-button__ripple-container">
            <span class="mdl-ripple">
            </span>
        </span>
    </button>

    <!-- Sidebar Avatar -->
    <div class="sidebar-image">
        <img src="/img/avatar.png" alt="wangchao's avatar">
    </div>

    <!-- Sidebar Email -->
    <a data-toggle="dropdown" class="sidebar-brand" href="#settings-dropdown">
        twilight0402@163.com
        <b class="caret"></b>
    </a>
</div>


        <!-- Sidebar Navigation  -->
        <ul class="nav sidebar-nav">
    <!-- User dropdown  -->
    <li class="dropdown">
        <ul id="settings-dropdown" class="dropdown-menu">
            
                <li>
                    <a href="http://mail.163.com" target="_blank" title="Email Me">
                        
                            <i class="material-icons sidebar-material-icons sidebar-indent-left1pc-element">email</i>
                        
                        Email Me
                    </a>
                </li>
            
        </ul>
    </li>

    <!-- Homepage -->
    
        <li id="sidebar-first-li">
            <a href="/" target="_self">
                
                    <i class="material-icons sidebar-material-icons">home</i>
                
                主页
            </a>
        </li>
        
    

    <!-- Archives  -->
    
        <li class="dropdown">
            <a href="#" class="ripple-effect dropdown-toggle" data-toggle="dropdown">
                
                    <i class="material-icons sidebar-material-icons">inbox</i>
                
                    归档
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
            <li>
                <a class="sidebar_archives-link" href="/archives/2017/08/">八月 2017<span class="sidebar_archives-count">5</span></a></li><li><a class="sidebar_archives-link" href="/archives/2017/07/">七月 2017<span class="sidebar_archives-count">23</span></a></li><li><a class="sidebar_archives-link" href="/archives/2017/06/">六月 2017<span class="sidebar_archives-count">13</span></a></li><li><a class="sidebar_archives-link" href="/archives/2017/04/">四月 2017<span class="sidebar_archives-count">7</span></a></li><li><a class="sidebar_archives-link" href="/archives/2017/03/">三月 2017<span class="sidebar_archives-count">3</span></a></li><li><a class="sidebar_archives-link" href="/archives/2017/02/">二月 2017<span class="sidebar_archives-count">2</span></a></li><li><a class="sidebar_archives-link" href="/archives/2017/01/">一月 2017<span class="sidebar_archives-count">8</span></a></li><li><a class="sidebar_archives-link" href="/archives/2016/12/">十二月 2016<span class="sidebar_archives-count">4</span></a></li><li><a class="sidebar_archives-link" href="/archives/2016/11/">十一月 2016<span class="sidebar_archives-count">3</span></a></li><li><a class="sidebar_archives-link" href="/archives/2016/09/">九月 2016<span class="sidebar_archives-count">3</span></a>
            </ul>
        </li>
        
    

    <!-- Categories  -->
    
        <li class="dropdown">
            <a href="#" class="ripple-effect dropdown-toggle" data-toggle="dropdown">
                
                    <i class="material-icons sidebar-material-icons">chrome_reader_mode</i>
                
                分类
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                <li>
                <a class="sidebar_archives-link" href="/categories/CSS/">CSS<span class="sidebar_archives-count">9</span></a></li><li><a class="sidebar_archives-link" href="/categories/HTML/">HTML<span class="sidebar_archives-count">3</span></a></li><li><a class="sidebar_archives-link" href="/categories/JSP/">JSP<span class="sidebar_archives-count">6</span></a></li><li><a class="sidebar_archives-link" href="/categories/Java/">Java<span class="sidebar_archives-count">8</span></a></li><li><a class="sidebar_archives-link" href="/categories/JavaScript/">JavaScript<span class="sidebar_archives-count">2</span></a></li><li><a class="sidebar_archives-link" href="/categories/Linux/">Linux<span class="sidebar_archives-count">13</span></a></li><li><a class="sidebar_archives-link" href="/categories/MySQL/">MySQL<span class="sidebar_archives-count">7</span></a></li><li><a class="sidebar_archives-link" href="/categories/Servlet/">Servlet<span class="sidebar_archives-count">9</span></a></li><li><a class="sidebar_archives-link" href="/categories/jQuery/">jQuery<span class="sidebar_archives-count">7</span></a></li><li><a class="sidebar_archives-link" href="/categories/技术/">技术<span class="sidebar_archives-count">2</span></a></li><li><a class="sidebar_archives-link" href="/categories/日常/">日常<span class="sidebar_archives-count">1</span></a></li><li><a class="sidebar_archives-link" href="/categories/随笔/">随笔<span class="sidebar_archives-count">3</span></a>
            </ul>
        </li>
        
    

    <!-- Pages  -->
    
        <li>
            <a href="/tags" title="标签云">
                
                    <i class="material-icons sidebar-material-icons">cloud</i>
                
                标签云
            </a>
        </li>
        
            <li class="divider"></li>
        
    
        <li>
            <a href="/about" title="About">
                
                    <i class="material-icons sidebar-material-icons">person</i>
                
                About
            </a>
        </li>
        
    
        <li>
            <a href="/links" title="Social">
                
                    <i class="material-icons sidebar-material-icons">equalizer</i>
                
                Social
            </a>
        </li>
        
    

    <!-- Article Number  -->
    
        <li>
            <a href="/archives">
                文章总数
                <span class="sidebar-badge">71</span>
            </a>
        </li>
        
    
</ul>


        <!-- Sidebar Footer -->
        <!--
I'm glad you use this theme, the development is no so easy, I hope you can keep the copyright, I will thank you so much.
If you still want to delete the copyrights, could you still retain the first one? Which namely "Theme Material"
It will not impact the appearance and can give developers a lot of support :)

很高兴您使用并喜欢该主题，开发不易 十分谢谢与希望您可以保留一下版权声明。
如果您仍然想删除的话 能否只保留第一项呢？即 "Theme Material"
它不会影响美观并可以给开发者很大的支持和动力。 :)
-->

<!-- Sidebar Divider -->

    <div class="sidebar-divider"></div>


<!-- Theme Material -->


<!-- Help & Support -->
<!--

-->

<!-- Feedback -->
<!--

    <a href="https://github.com/viosey/hexo-theme-material/issues" target="_blank" class="sidebar-footer-text-a">
        <div class="sidebar-text mdl-button mdl-js-button mdl-js-ripple-effect sidebar-footer-text-div" data-upgraded=",MaterialButton,MaterialRipple">
        sidebar.feedback
        <span class="mdl-button__ripple-container"><span class="mdl-ripple"></span></span></div>
    </a>

-->

<!-- About Theme -->
<!--

    <a href="https://blog.viosey.com/index.php/Material.html" target="_blank" class="sidebar-footer-text-a">
        <div class="sidebar-text mdl-button mdl-js-button mdl-js-ripple-effect sidebar-footer-text-div" data-upgraded=",MaterialButton,MaterialRipple">
             sidebar.about_theme
            <span class="mdl-button__ripple-container"><span class="mdl-ripple"></span></span></div>
    </a>

-->

    </div>

    <!-- Sidebar Image -->
    

</aside>

                    

                    
                        <!-- Footer Top Button -->
                        <div class="toTop-wrap">
    <a href="#top" class="toTop">
        <i class="material-icons footer_top-i">expand_less</i>
    </a>
</div>

                    

                    <!--Footer-->
<footer class="mdl-mini-footer" id="bottom">
    
        <!-- Paradox Footer Left Section -->
        <div class="mdl-mini-footer--left-section sns-list">
    <!-- Twitter -->
    
        <a href="https://twitter.com/twitter" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-twitter.svg);">
                <span class="visuallyhidden">Twitter</span>
            </button><!--
     --></a>
    

    <!-- Facebook -->
    
        <a href="https://www.facebook.com/facebook" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-facebook.svg);">
                <span class="visuallyhidden">Facebook</span>
            </button><!--
     --></a>
    

    <!-- Google + -->
    
        <a href="https://www.google.com/" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-gplus.svg);">
                <span class="visuallyhidden">Google Plus</span>
            </button><!--
     --></a>
    

    <!-- Weibo -->
    

    <!-- Instagram -->
    

    <!-- Tumblr -->
    

    <!-- Github -->
    
        <a href="https://github.com/1601436878" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-github.svg);">
                <span class="visuallyhidden">Github</span>
            </button><!--
     --></a>
    

    <!-- LinkedIn -->
    

    <!-- Zhihu -->
    
        <a href="https://www.zhihu.com/people/wang-chao-50-78/activities" target="_blank">
            <button class="mdl-mini-footer--social-btn social-btn" style="background-image: url(/img/footer/footer_ico-zhihu.svg);">
                <span class="visuallyhidden">Zhihu</span>
            </button><!--
     --></a>
    

    <!-- Bilibili -->
    

    <!-- Telegram -->
    
</div>


        <!--Copyright-->
        <div id="copyright">
            Copyright&nbsp;©&nbsp;
            <script type="text/javascript">
                var fd = new Date();
                document.write(fd.getFullYear());
            </script>
            &nbsp;Twilight's Blog
        </div>

        <!-- Paradox Footer Right Section -->

        <!--
        I am glad you use this theme, the development is no so easy, I hope you can keep the copyright.
        It will not impact the appearance and can give developers a lot of support :)

        很高兴您使用该主题，开发不易，希望您可以保留一下版权声明。
        它不会影响美观并可以给开发者很大的支持。 :)
        -->

        <div class="mdl-mini-footer--right-section">
            <div>
                <div class="footer-develop-div">Powered by <a href="https://hexo.io" target="_blank" class="footer-develop-a">Hexo</a></div>
                <div class="footer-develop-div">Theme - <a href="https://github.com/viosey/hexo-theme-material" target="_blank" class="footer-develop-a">Material</a></div>
            </div>
        </div>
    
</footer>


                    <!-- Import File -->

    <script src="/js/lazyload.min.js"></script>
    <script src="/js/js.min.js"></script>



    <script src="/js/nprogress.js"></script>


<script type="text/javascript">
    NProgress.configure({
        showSpinner: true
    });
    NProgress.start();
    $('#nprogress .bar').css({
        'background': '#29d'
    });
    $('#nprogress .peg').css({
        'box-shadow': '0 0 10px #29d, 0 0 15px #29d'
    });
    $('#nprogress .spinner-icon').css({
        'border-top-color': '#29d',
        'border-left-color': '#29d'
    });
    setTimeout(function() {
        NProgress.done();
        $('.fade').removeClass('out');
    }, 800);
</script>





    <!-- Leancloud -->
    <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
    <script>
        AV.initialize('WJXlEXdVypRaytiRUYDL9Q4w-gzGzoHsz', 'qNN24AGgbaMqnDE7lqK8pwCD');
    </script>
    <script>
    function showTime(Counter) {
        var query = new AV.Query(Counter);
        $('.leancloud-views_num').each(function() {
            var url = $(this).attr('id').trim();
            query.equalTo('url', url);
            query.find({
                success: function(results) {
                    if (results.length === 0) {
                        var content = '0 ' + $(document.getElementById(url)).text();
                        $(document.getElementById(url)).text(content);
                        return;
                    }
                    for (var i = 0; i < results.length; i++) {
                        var object = results[i];
                        var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
                        $(document.getElementById(url)).text(content);
                    }
                },
                error: function(object, error) {
                    console.log('Error: ' + error.code + ' ' + error.message);
                }
            });
        });
    }

    function addCount(Counter) {
      var Counter = AV.Object.extend('Counter');
      url = $('.leancloud-views_num').attr('id').trim();
      title = $('.leancloud-views_num').attr('data-flag-title').trim();
      var query = new AV.Query(Counter);
      query.equalTo('url', url);
      query.find({
          success: function(results) {
            if (results.length > 0) {
                var counter = results[0];
                counter.fetchWhenSave(true);
                counter.increment('time');
                counter.save(null, {
                    success: function(counter) {
                        var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
                        $(document.getElementById(url)).text(content);
                    },
                    error: function(counter, error) {
                        console.log('Failed to save Visitor num, with error message: ' + error.message);
                    }
                });
            } else {
              var newcounter = new Counter();
              newcounter.set('title', title);
              newcounter.set('url', url);
              newcounter.set('time', 1);
              newcounter.save(null, {
                  success: function(newcounter) {
                      console.log('newcounter.get(\'time\')='+newcounter.get('time'));
                      var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
                      $(document.getElementById(url)).text(content);
                  },
                  error: function(newcounter, error) {
                      console.log('Failed to create');
                  }
              });
            }
        },
        error: function(error) {
            console.log('Error:' + error.code + ' ' + error.message);
        }
      });
    }
    $(function() {
        var Counter = AV.Object.extend('Counter');
        if ($('.leancloud-views_num').length === 1) {
            addCount(Counter);
        } else if ($('.post-title-link').length > 1) {
            showTime(Counter);
        }
    });
</script>







    <!-- 畅言公共 js 代码 start -->
		<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=cysVH2p6S">
</script>
    <!-- 畅言公共 js 代码 end -->







<!-- Window Load-->
<script>
    $(window).load(function() {
        // Post_Toc parent position fixed
        $('.post-toc-wrap').parent('.mdl-menu__container').css('position', 'fixed');
    });
</script>

<!-- MathJax Load-->

<script>
    <!-- Offer LazyLoad -->
    queue.offer(function(){
        $('.lazy').lazyload({
            effect : 'show'
        });
    });

    <!-- Start Queue -->
    $(document).ready(function(){
        setInterval(function(){
            queue.execNext();
        },200);
    });
</script>

                </main>
            </div>
			<!--  -->
				<!--<script type="text/javascript" count="200" color="0,0,255" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>-->
			<!--  -->
        </body>
    
</html>
